//
//  MovieTableViewCell.m
//  Movie
//
//  Created by mycomputer on 15/7/20.
//  Copyright (c) 2015年 杨韦智. All rights reserved.
//

#import "MovieTableViewCell.h"


@implementation MovieTableViewCell

- (void)awakeFromNib {
  
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

- (void)setModel:(MovieModel *)model {
    _model = model;
    
    [self setNeedsLayout];
}

- (void)layoutSubviews {
    NSString *imageStr = [_model.images objectForKey:@"small"];
    [_cellImageView sd_setImageWithURL:[NSURL URLWithString:imageStr]];
    _yearLabel.text = [NSString stringWithFormat:@"年份  %@",_model.year];
    _titleLabel.text = _model.title;
    _averageLabel.text = [NSString stringWithFormat:@"%.1f",_model.average];
    _starView.average = _model.average;
    //_starView
    
}

- (void)textt {
        CGFloat average = _model.average;
        UIImage *image1 = [UIImage imageNamed:@"yellow"];
        UIImage *image2 = [UIImage imageNamed:@"gray"];
        UIImageView *imgView1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 10, image1.size.width*average/2, image1.size.height)];
        imgView1.backgroundColor = [UIColor colorWithPatternImage:image1];
        UIImageView *imgView2 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 10, image1.size.width*5, image1.size.height)];
        imgView2.backgroundColor = [UIColor colorWithPatternImage:image2];
        [_starView addSubview:imgView2];
        [_starView addSubview:imgView1];
    
        [_cellImageView addSubview:_starView];
}

@end
